package tp.badugi.bot;

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class CardExchangeNoDoublesTest {

	private BotPrudentCardExchangeStrategy botCardExchanger;
	
	@Before
	public void before() throws Exception {
		this.botCardExchanger = new BotPrudentCardExchangeStrategy();
	}
	
	@After
	public void after() throws Exception {
	}
	
	@Test
	public void Given_AC_2D_3H_4S_Expected_Empty(){
		String givenCards[] = new String[]{"AC","2D","3H","4S"};
		String expectedResult[] = new String[]{};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		Assert.assertArrayEquals(expectedResult, botResult);
	}
	
	@Test
	public void Given_2C_5D_6H_7S_Expected_Empty(){
		String givenCards[] = new String[]{"2C","5D","6H","7S"};
		String expectedResult[] = new String[]{};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		Assert.assertArrayEquals(expectedResult, botResult);
	}
	
	@Test
	public void Given_3C_4D_5H_6S_Expected_6S(){
		String givenCards[] = new String[]{"3C","4D","5H","6S"};
		String expectedResult[] = new String[]{"6S"};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		Assert.assertArrayEquals(expectedResult, botResult);
	}
	
	@Test
	public void Given_AC_4D_5H_8S_Expected_8S(){
		String givenCards[] = new String[]{"AC","4D","5H","8S"};
		String expectedResult[] = new String[]{"8S"};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		Assert.assertArrayEquals(expectedResult, botResult);
	}
	
	@Test
	public void Given_AC_KD_5H_8S_Expected_8S_KD(){
		String givenCards[] = new String[]{"AC","KD","5H","8S"};
		String expectedResult[] = new String[]{"8S","KD"};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		List<String> botResultList = Arrays.asList(botResult);
		
		List<String> expectedResultList = Arrays.asList(expectedResult);
		
		assertTrue((expectedResultList.containsAll(botResultList) && botResultList.containsAll(expectedResultList)) );
	}
	
	@Test
	public void Given_8C_KD_QH_TS_Expected_8S(){
		String givenCards[] = new String[]{"8C","KD","QH","TS"};
		String expectedResult[] = new String[]{"8C","KD","QH","TS"};
		
		String botResult[] = this.botCardExchanger.exchangeCards(givenCards);
		
		List<String> botResultList = Arrays.asList(botResult);
		
		List<String> expectedResultList = Arrays.asList(expectedResult);
		
		assertTrue((expectedResultList.containsAll(botResultList) && botResultList.containsAll(expectedResultList)) );
	}

}
